package com.ybf.api.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.github.pagehelper.PageHelper;
import com.ybf.api.entity.PageRequest;
import com.ybf.api.entity.PageResult;
import com.ybf.api.entity.UserRoles;
import com.ybf.api.mapper.UserRolesMapper;
import com.ybf.api.service.UserRolesService;
import com.ybf.api.utils.EncryptUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ybf
 * @since 2024-09-26
 */
@Service("UserRolesService")
public class UserRolesImpl implements UserRolesService {

    @Resource
    private UserRolesMapper userrolesMapper;

    @Override
    public PageResult<UserRoles> list(UserRoles userroles, PageRequest pageRequest) {
        PageHelper.startPage(pageRequest);
        List<UserRoles> list = userrolesMapper.list(userroles);
        PageResult<UserRoles> pageResult = new PageResult<UserRoles>(list);
        return pageResult;
    }

    @Override
    public UserRoles info(Integer id) {
        return userrolesMapper.info(id);
    }

    @Override
    public Boolean delete(Integer id) {
        return userrolesMapper.delete(id) > 0;
    }

    @Override
    public Integer edit(UserRoles userroles) {
        if (userroles.getId() != null) {
            return userrolesMapper.edit(userroles);
        }
        return userrolesMapper.add(userroles);
    }
}
